package com.woniuxy;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.FileSystemResource;

public class IocTest {
    public static void main(String[] args) {
        BeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource("appliacationContext.xml"));
        Person chinese = beanFactory.getBean("chinese", Person.class);
        Person chinese1 = beanFactory.getBean("chinese", Person.class);
        System.out.println(chinese);
        System.out.println(chinese1);

        ApplicationContext applicationContext = new FileSystemXmlApplicationContext("C:\\Users\\25474\\Downloads\\Compressed\\java-85-course-code\\Day02\\src\\appliacationContext.xml");
        Person chinese2 = applicationContext.getBean("chinese", Person.class);
        Person chinese3 = applicationContext.getBean("chinese", Person.class);
        System.out.println(chinese2);
        System.out.println(chinese3);
        Person bean = applicationContext.getBean("com.woniuxy.impl.America", Person.class);
        Person ch1 = applicationContext.getBean("ch1", Person.class);
        ch1.play();
        bean.play();
        System.out.println(ch1);

        System.out.println(bean);

    }
}
